import 'virtual:uno.css'

import { setupRouter } from '@/router'
import { setupStore } from '@/store'

import App from '@/App.vue'

import InstallGlobalComponents from '@/components'
// 引入viewer的样式
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
const app = createApp(App)

app.use(VueViewer)

function setupPlugins() {
    app.use(InstallGlobalComponents)
}

async function setupApp() {
    setupStore(app)
    await setupRouter(app)
    app.mount('#app')
}

setupPlugins()
setupApp()

// 初始化用户状态 - 设置为默认登录状态
const userStore = useUserStore()
userStore.init()
// // 确保用户始终处于登录状态
// if (!userStore.isLoggedIn) {
//     userStore.login({ token: 'default-token' })
// }

export default app
